package com.foreveross.dao.imp;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.foreveross.common.SQLUtil;
import com.foreveross.dao.ExpressDAO;
import com.foreveross.dao.HrBusinessDAO;
import com.foreveross.dao.HrFavorableDAO;
import com.foreveross.vo.Express;
import com.foreveross.vo.HouseLease;
import com.foreveross.vo.HrBusiness;
import com.foreveross.vo.HrFavorable;
import com.foreveross.vo.ProductType;
import com.foreveross.vo.Tenement;
import com.foreveross.vo.common.PageVo;
import com.foreveross.vo.common.ResultVo;

@Component("hrBusinessDAO")
public class HrBusinessDAOImp extends SQLUtil implements HrBusinessDAO {

	@Override
	public long getHrBusinessListCount(String userId,String name,String houseId) throws Exception {
		StringBuffer strbuBuffer = new StringBuffer();
		strbuBuffer.append(" select count(*) from HrBusiness model where 1=1 ");
		if (!"".equals(name) && null != name) {
			strbuBuffer.append(" and model.name='"+name+"' ");
		}
		if (!"".equals(houseId) && null != houseId) {
			strbuBuffer.append(" and model.houseId='"+houseId+"' ");
		}
		this.addAuthorityStr(strbuBuffer, userId,  "houseId");
		return Long.parseLong(findObejctByHql(strbuBuffer.toString()).toString());
	}

	@Override
	public List<HrBusiness> getHrBusinessList(String userId,String name,String houseId, int pageIndex,
			int pageSize) throws Exception {
		StringBuffer strbuBuffer = new StringBuffer();
		strbuBuffer.append(" select model from HrBusiness model where 1=1 ");
		if (!"".equals(name) && null != name) {
			strbuBuffer.append(" and model.name='"+name+"' ");
		}
		if (!"".equals(houseId) && null != houseId) {
			strbuBuffer.append(" and model.houseId='"+houseId+"' ");
		}
		this.addAuthorityStr(strbuBuffer, userId,  "houseId");
		return (List<HrBusiness>) findObjectAll(strbuBuffer.toString(), pageIndex,pageSize);
	}


}
